﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BacteriaSimulation.Simulation
{
    public class IndexGridCell
    {
        public int RowIndex { get; set; }
        public int ColumnIndex { get; set; }

        public List<Bacterium> Bacteria { get; set; }

        protected List<IndexGridCell> adjacentCells;

        public IndexGridCell(int rowIndex, int columnIndex)
        {
            this.RowIndex = rowIndex;
            this.ColumnIndex = columnIndex;

            this.Bacteria = new List<Bacterium>();
        }

        public void AddBacterium(Bacterium bacteriumToAdd)
        {
            if (!Bacteria.Contains(bacteriumToAdd))
            {
                Bacteria.Add(bacteriumToAdd);
                bacteriumToAdd.Cell = this;
            }
        }

        public void RemoveBacterium(Bacterium bacteriumToRemove)
        {
            if (this.Bacteria.Contains(bacteriumToRemove))
            {
                this.Bacteria.Remove(bacteriumToRemove);
                bacteriumToRemove.Cell = null;
            }
        }
    }
}
